package com.ruoyi.web.controller.nycbfx;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nycbfx.domain.TbNycbfxNydjwh;
import com.ruoyi.nycbfx.service.ITbNycbfxNydjwhService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源单价维护Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@RestController
@RequestMapping("/nycbfx/nydjwh")
public class TbNycbfxNydjwhController extends BaseController
{
    @Autowired
    private ITbNycbfxNydjwhService tbNycbfxNydjwhService;

    /**
     * 查询能源单价维护列表
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbNycbfxNydjwh tbNycbfxNydjwh)
    {
        startPage();
        List<TbNycbfxNydjwh> list = tbNycbfxNydjwhService.selectTbNycbfxNydjwhList(tbNycbfxNydjwh);
        return getDataTable(list);
    }

    /**
     * 导出能源单价维护列表
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:export')")
    @Log(title = "能源单价维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbNycbfxNydjwh tbNycbfxNydjwh)
    {
        List<TbNycbfxNydjwh> list = tbNycbfxNydjwhService.selectTbNycbfxNydjwhList(tbNycbfxNydjwh);
        ExcelUtil<TbNycbfxNydjwh> util = new ExcelUtil<TbNycbfxNydjwh>(TbNycbfxNydjwh.class);
        util.exportExcel(response, list, "能源单价维护数据");
    }

    /**
     * 获取能源单价维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbNycbfxNydjwhService.selectTbNycbfxNydjwhById(id));
    }

    /**
     * 新增能源单价维护
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:add')")
    @Log(title = "能源单价维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbNycbfxNydjwh tbNycbfxNydjwh)
    {
        return toAjax(tbNycbfxNydjwhService.insertTbNycbfxNydjwh(tbNycbfxNydjwh));
    }

    /**
     * 修改能源单价维护
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:edit')")
    @Log(title = "能源单价维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbNycbfxNydjwh tbNycbfxNydjwh)
    {
        return toAjax(tbNycbfxNydjwhService.updateTbNycbfxNydjwh(tbNycbfxNydjwh));
    }

    /**
     * 删除能源单价维护
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nydjwh:remove')")
    @Log(title = "能源单价维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbNycbfxNydjwhService.deleteTbNycbfxNydjwhByIds(ids));
    }
}
